package com.example.huadi1.controller;

import com.example.huadi1.service.BuyBookService;
import com.example.huadi1.utils.AjaxResult;
import com.example.huadi1.utils.Request.PageRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/buyBook")
@Slf4j
public class BuyBookController {
    @Autowired
    private BuyBookService buyBookService;
    @PostMapping("/create")
    public AjaxResult getDemands(){
        AjaxResult result=buyBookService.createBuyBook();
        return result;
    }

    @PostMapping("/buy")
    public AjaxResult buyBook() {
        return buyBookService.buyTextbook();
    }

    @PostMapping("/query")
    public AjaxResult allBuyBook(@RequestBody PageRequest pageRequest){
        System.out.println(pageRequest.toString());
        return buyBookService.queryBuyBook(pageRequest);}
}
